/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Graphisme;

import HotelsData.Hotel;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import moyensDeTransport.Avion;
import moyensDeTransport.Bateau;

/**
 *
 * @author BENAMMAR Riyadh
 */
public class Resultat {
    private List<Object> donneesDepart=new ArrayList<>();
    private List<Object> donneesSejour=new ArrayList<>();
    private List<Object> donneesRetour=new ArrayList<>();
    
    public Resultat(List<Object> depart,List<Object> retour, List<Object> sejour){
        donneesDepart=depart;
        donneesSejour=sejour;
        donneesRetour=retour;
    }
    
    public int size(){
        return donneesDepart.size()+donneesRetour.size();
    }
    
    public JPanel getAssociatedPanel(List<Object> data){
        JPanel aRetourner=new JPanel(new FlowLayout());
        aRetourner.setBorder(BorderFactory.createLineBorder(Color.blue));
        
        for(Object o:data){
            if (o instanceof Avion){
            final Avion avion= (Avion) o;
            JButton bouton=avion.getBouton();
            bouton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    JDialog dialog=new JDialog();
                    dialog.setModal(true);
                    dialog.add(avion.getPanel());
                    dialog.pack();
                    dialog.setVisible(true);      
                    
                }
            });
            aRetourner.add(bouton);
        } else if (o instanceof HotelsData.Hotel){
            final HotelsData.Hotel hotel= (Hotel) o;
                JButton bouton=hotel.getBouton();
                bouton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    JDialog dialog=new JDialog();
                    dialog.setModal(true);
                    dialog.add(hotel.getPanel());
                    dialog.pack();
                    dialog.setVisible(true);      
                    
                }
            });
            aRetourner.add(bouton);
        } else if (o instanceof Bateau){
            final Bateau bateau= (Bateau) o;
                JButton bouton=bateau.getBouton();
                bouton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    JDialog dialog=new JDialog();
                    dialog.setModal(true);
                    dialog.add(bateau.getPanel());
                    dialog.pack();
                    dialog.setVisible(true);      
                    
                }
            });
            aRetourner.add(bouton);
        } else aRetourner.add(new JLabel(" ... "));
        }
        
        return aRetourner;
    }

    public List<Object> getDonneesDepart() {
        return donneesDepart;
    }

    public List<Object> getDonneesRetour() {
        return donneesRetour;
    }

    public List<Object> getDonneesSejour() {
        return donneesSejour;
    }
    
    
}
